#include "qrcode.h"
#include <QNetworkAccessManager>
#include <QDebug>
#include <QEventLoop>
#include <QPixmap>
#include <QTimer>

QrCode::QrCode()
{
    qDebug() << "QrCode:" << QThread::currentThread();
    status = LOGIN_STATUS::WAIT_SCAN;
    qRegisterMetaType<LOGIN_STATUS>("LOGIN_STATUS");//注册LOGIN_STATUS类型

//    QThread *httpThread = new QThread;
//    httpRequest = new HttpRequestThread();
    httpRequest.qrCode = this;
    httpRequest.moveToThread(&thread);
    thread.start();
    connect(this, SIGNAL(tr()), &httpRequest, SLOT(run()), Qt::QueuedConnection);
    connect(this, SIGNAL(okChanged()), &thread, SLOT(quit()), Qt::QueuedConnection);
    tr();
}

QrCode::~QrCode()
{
    qDebug() << "~QrCode";
    thread.quit();
    thread.wait();
//    delete httpRequest;
}

QString QrCode::getImgUrl() const
{
    return imgUrl;
}

void QrCode::setImgUrl(const QString &value)
{
    imgUrl = value;
    imgUrlChanged(value);
}

QrCode::LOGIN_STATUS QrCode::getStatus() const
{
    return status;
}

void QrCode::setStatus(const LOGIN_STATUS &value)
{
    status = value;
    statusChanged(value);
}

bool QrCode::getOk() const
{
    return ok;
}

void QrCode::setOk(bool value)
{
    okChanged();
    ok = value;
}


QColor QrCode::getColor() const
{
    return color;
}

void QrCode::setColor(const QColor &value)
{
    color = value;
}
QString QrCode::getUuid() const
{
    return uuid;
}

void QrCode::setUuid(const QString &value)
{
    uuid = value;
    uuidChanged(value);
}
